package org.example.demo.apiv2.sql;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.Alias;
import net.sf.jsqlparser.schema.Table;

@Slf4j
public class TableParser {

    /**
     * 构造jsqlparser的Table对象
     *
     * @param tableName
     * @param tableAlias
     * @param useAs
     * @return
     */
    public static Table getTable(String tableName, String tableAlias, boolean useAs) {
        Table table = new Table(tableName);
        if (StrUtil.isNotEmpty(tableAlias)) {
            table.setAlias(new Alias(tableAlias, useAs));
        }
        return table;
    }
}
